# -*- coding: cp936 -*-
import sys, pygame
import random
from pygame.locals import *

pygame.init()

tiles, block = 24, 20
size = width, height = (tiles * block), (tiles * block + 10)

dirs = up, right, down, left = (-tiles, 1, tiles, -1)
view = (up, right, down, left, up - 1, up + 1, down - 1, down + 1)

hall, wall, boundary, extra = 0, 1, 2, 3

red, green, blue = (255, 0, 0), (0, 255, 0), (0, 0, 255)
white, grey, black = (255, 255, 255), (100, 100, 100), (0, 0, 0)

font = pygame.font.Font(None, 14)
clock = pygame.time.Clock()
screen = pygame.display.set_mode(size)

def make_maze():
    global maze, player, end, moves

    maze = [boundary] * tiles
    maze += ([boundary] + [hall] * (tiles - 2) + [boundary]) * (tiles - 2)
    maze += [boundary] * tiles
    
def draw_tile(func, color, pos):
    #求出小矩形的左上角的坐标
    left = (pos % tiles) * block
    top = (pos / tiles) * block
    
    #绘制一个矩形
    #screen 表示区域
    #color 颜色
    #（left，top） 小矩形左上角的左边
    #（block，block）小矩形的宽高
    func(screen, color, (left, top, block, block))

def draw_maze():
    #pos 表示maze列表中 val 所对应的下标
    for pos, val in enumerate(maze):
        color = white if val == hall else black
        draw_tile(pygame.draw.rect, color, pos)

make_maze()
draw_maze()

while True:
    clock.tick(12)

    event = pygame.event.poll()
    move_dir = None

    if event.type == pygame.QUIT:
        pygame.quit()
        sys.exit()
   

    

    pygame.display.flip()
